package me.zhengjie

//import com.zaxxer.hikari.HikariDataSource
import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import java.sql.Connection
import java.sql.ResultSet
import java.sql.Statement
import javax.sql.DataSource

//@SpringBootTest
class JdbcSimpleDatasourceApplicationTests constructor() {
    /*private val logger: Logger = LoggerFactory.getLogger(JdbcSimpleDatasourceApplicationTests::class.java)
    @Autowired
    private var dataSource: DataSource? = null

    fun springDataSourceTest() {
        //输出为true
        if (dataSource is HikariDataSource) {
            logger.info("ataSource is HikariDataSource = true")
        }else{
            logger.info("ataSource is HikariDataSource = false")
        }

        try {
            val connection: Connection? = dataSource!!.connection
            val statement: Statement? = connection!!.createStatement()
            val resultSet: ResultSet? = statement!!.executeQuery("select * from user")
            if (resultSet!!.next()) {
                logger.info("id={}",resultSet.getString("id"))
                logger.info("email={}",resultSet.getString("email"))
                logger.info("username={}",resultSet.getString("username"))
                logger.info("phone={}",resultSet.getString("phone"))
            }
            System.out.println(resultSet.toString())
            statement.close()
            connection.close()
        } catch (exception: java.lang.Exception) {
            exception.printStackTrace()
        }
    }*/
}